package com.ruoyi.web.controller.news.api;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.news.NewsTechnologyCommunicate;
import com.ruoyi.system.domain.news.query.NewsTechnologyCommunicateQuery;
import com.ruoyi.system.domain.news.vo.NewsTechnologyCommunicateVo;
import com.ruoyi.system.service.news.NewsTechnologyCommunicateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/news/newsTechnologyCommunicate")
@Api(value = "newsTechnologyCommunicateApiController", tags  = "学术研讨Api")
public class NewsTechnologyCommunicateApiController extends BaseController {

	@Resource
	private NewsTechnologyCommunicateService newsTechnologyCommunicateService;

	@ApiOperation(value = "获取单个学术研讨信息", notes = "获取单个学术研讨信息")
	@GetMapping("/getById")
	public R<NewsTechnologyCommunicate> getById(@RequestParam(value = "id") Long id) {
		NewsTechnologyCommunicateQuery newsTechnologyCommunicateQuery = new NewsTechnologyCommunicateQuery();
		newsTechnologyCommunicateQuery.setId(id);
		List<NewsTechnologyCommunicateVo> newsTechnologyCommunicateList = newsTechnologyCommunicateService.getNewsTechnologyCommunicateList(newsTechnologyCommunicateQuery);
		if (newsTechnologyCommunicateList!=null&&newsTechnologyCommunicateList.size()>0) {
			return R.ok(newsTechnologyCommunicateList.get(0));
		} else {
			return R.fail("数据不存在");
		}
	}

	@ApiOperation(value = "获取学术研讨信息列表")
	@PostMapping(value = "/list")
	public R<PageInfo<NewsTechnologyCommunicateVo>> list(@RequestBody NewsTechnologyCommunicateQuery newsTechnologyCommunicateQuery) {
        newsTechnologyCommunicateQuery.setIsEnable("1");
		List<NewsTechnologyCommunicateVo> newsTechnologyCommunicateList = newsTechnologyCommunicateService.getNewsTechnologyCommunicateList(newsTechnologyCommunicateQuery);
		return R.ok(new PageInfo<>(newsTechnologyCommunicateList));
	}
}
